﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CardDataWCFService
{
    public static class GameLogic
    {
        public static Player AddPlayer(Player player)
        {
            using (CardLINQDataContext context = new CardLINQDataContext())
            {
                context.Players.InsertOnSubmit(player);
                context.SubmitChanges();

                //Return new player to verify playerID
                var players = from newplayer in context.Players
                              where player.PlayerName.ToLower().Equals(player.PlayerName.ToLower())
                              select newplayer;
                Player returnPlayer = players.First();

                return returnPlayer;
            }
        }
    }
}
